package com.tn.task;


import com.tn.controller.alarm.common.model.camera.vo.CameraVO;
import com.tn.dao.camera.ICameraDao;
import com.tn.utils.JsonUtil;
import com.tn.utils.redis.RedisUtils;
import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;


@Component
@Slf4j
public class RedisTask {

    @Autowired
    private ICameraDao dao;

    //Scheduled(cron = "0/1 * * * * ?")
    @Scheduled(cron = "0 0/5 * * * ?")
    public void executeRedisTask() {
        //查询所有的摄像头
        List<CameraVO> cameraVOS = dao.queryCameraList();
        String s = JsonUtil.obj2String(cameraVOS);
        RedisUtils.setCacheObject("camera_info",s);
    }
}
